<template>
    <div class="card">
        <!-- {{this.cardData}} -->
        <div class="block">
            <div v-if="this.cardData == ''" class="noEquipment"> 
                该项绑定设备未开启
            </div>
            <el-carousel trigger="click" class="card_hight" :autoplay="false" :initial-index="cardData.index" >
            <el-carousel-item v-for="item in cardData.unit" :key="item.index">
                <!-- 设备标题 -->
                <router-link to="/overview">
                    <h4 class="normal" @click="router('k8s',item)" :title="item.name">
                    <img class="title_icon" src="../../assets/title.png" alt />
                    {{item.typename}}:&nbsp;{{item.name}}
                 </h4>
                </router-link>

                <!-- 卡片内容 -->
                <div class="card_padding">
                    <div class="k8s_left">
                        <div class="k8s_left_div">
                            <div class="card_c">
                                <el-progress type="circle" :show-text="false" :stroke-width="3" :width="70" :percentage="numc(item.unit[5].value,item.unit[5].min,item.unit[5].max)" color="#0168B7" stroke-linecap="butt"></el-progress>
                                <p class="card_chart_name">环境温度</p>
                                <p class="card_chart_value">{{item.unit[5].value.toFixed(1)}}</p>
                                <p class="card_chart_flag">{{item.unit[5].flag}}</p>
                            </div>
                            <div class="card_c">
                                <el-progress type="circle" :show-text="false" :stroke-width="3" :width="70" :percentage="numc(item.unit[6].value,item.unit[6].min,item.unit[6].max)" color="#38BDEA" stroke-linecap="butt"></el-progress>
                                <p class="card_chart_name">相对湿度</p>
                                <p class="card_chart_value">{{item.unit[6].value.toFixed(1)}}</p>
                                <p class="card_chart_flag">{{item.unit[6].flag}}</p>
                            </div>
                        </div>
                        <div class="k8s_left_div" style="margin-top: -42px;">
                            <div class="card_c">
                                <p class="k8sCard_pm_value" style="color:#0168B7">{{item.unit[3].value.toFixed(0)}}</p>
                                <p class="k8sCard_pm_flag">{{item.unit[3].flag}}</p>
                                <p class="card_chart_name">{{item.unit[3].name}}</p>
                            </div>
                            <div class="card_c">
                                <p class="k8sCard_pm_value" style="color:#38BDEA">{{item.unit[4].value.toFixed(0)}}</p>
                                <p class="k8sCard_pm_flag">{{item.unit[4].flag}}</p>
                                <p class="card_chart_name">{{item.unit[4].name}}</p>
                            </div>
                        </div>
                    </div>
                    <div class="k8s_right">
                        <ul>
                            <li class="k8s_li">
                                <p class="k8s_li_p1">{{item.unit[1].name}}:</p>
                                <p class="k8s_li_p2">{{item.unit[1].value.toFixed(0)}}<span>{{item.unit[1].flag}}</span></p>
                            </li>
                            <li class="k8s_li">
                                <p class="k8s_li_p1">{{item.unit[2].name}}:</p>
                                <p class="k8s_li_p2">{{item.unit[2].value.toFixed(0)}}<span>{{item.unit[2].flag}}</span></p>
                            </li>
                            <li class="k8s_li">
                                <p class="k8s_li_p1">{{item.unit[0].name}}:</p>
                                <p class="k8s_li_p2">{{item.unit[0].value.toFixed(0)}}<span>{{item.unit[0].flag}}</span></p>
                            </li>
                            <li class="k8s_li">
                                <p class="k8s_li_p1">{{item.unit[7].name}}:</p>
                                <p class="k8s_li_p2">{{item.unit[7].value.toFixed(0)}}<span>{{item.unit[7].flag}}</span></p>
                            </li>
                            <li class="k8s_li">
                                <p class="k8s_li_p1">烟雾:</p>
                                <p class="k8s_li_p2">{{item.unit[7].value.toFixed(0)}}<span>μg/m³</span></p>
                            </li>
                        </ul>
                    </div>
                </div>
                 
            </el-carousel-item>
            </el-carousel>
        </div>
        
    </div>
</template>

<script>
export default {
    props: ['nowIndex', 'cardData', 'nowId'],
    data () {
        return{
        }
    },
    created() {
        // this.getCardData();
        // // 从缓存获取数据定时器
        // this.timergetCardData = setInterval(() => {
        // setTimeout(this.getCardData(), 0);
        // }, this.$store.state.requestTime);
    },
    methods: {
        // 跳转
        router(val,item){
            var arr = {
                addr:item.addr,
                name:item.name,
                type:item.type,
                uid:item.uid
            }
            localStorage.setItem("当前设备编号", JSON.stringify(arr))
            localStorage.setItem("menuRouter", val)
        },
        numc(a,b,c){
            var s = ((a-b) /(c - b)) *100
            if(s > 100){
                s = 1
            }else if(s < 0){
                s = 0
            }
            return s
        },
    },
     // 清除定时器
    beforeDestroy() {
        // alert("已经销毁了")
    },
}
</script>

<style scoped>

/deep/ .el-carousel__container .el-carousel__arrow {
    height: 150px !important;
    width: 110px !important;
    border-radius: 0;
    background: none;
}
/deep/ .el-icon-arrow-left {
    margin-left: -110px !important;
}
/deep/ .el-icon-arrow-right{
    margin-right: -110px !important;
}
/deep/ .el-carousel__indicators{
    display: none;
}
.normal .card_icon{
    font-size: 20px;
}
/deep/ .card_padding {
    padding: 0px 20px 0px 30px !important;
    display: flex;
}
.k8s_left{
    flex: 1;
    padding-top: 10px;
}
.k8s_left_div{
    display: flex;
    text-align: center;
}
.card_c{
    flex: 1;
}
.card_chart_value{
    position: relative;
    top: -80px;
}
.k8sCard_pm_value{
    font-size: 30px;
    line-height: 37px;
    margin-top: 10px;
    /* color: #38BDEA; */
}
.k8sCard_pm_flag{
    font-size: 15px;
    color: #acacac;
    margin-left: 5px;
    margin-bottom: 5px;
}
.card_chart_flag{
    font-size: 15px;
    color: #acacac;
    position: relative;
    top: -80px;
}
.card_chart_name{
    margin-top: 10px;
}
.k8s_right{
    flex: 1;
    padding-left: 10px;
}
.k8s_li{
    display: flex;
    /* 三条展示样式 */
    /* height: 70px;
    line-height: 76px; */
    /* 四条展示样式 */
      height: 50px;
    line-height: 56px;
    /*  */
    border-bottom:5px solid;
    border-image: linear-gradient(to bottom , #fff0, #8fc6ffa3)100 0;
    background: linear-gradient(to bottom , rgba(255, 0, 0, 0), #8fc6ffa3 300%);
    margin-bottom: 5px;
    text-indent: 10px;
}
.k8s_li_p1{
    width: 70px;
    font-size: 17px;
    overflow: hidden;
}
.k8s_li_p2{
    font-size: 25px;
    color: #38bdea;
}
.k8s_li_p2 span{
    font-size: 15px;
    color: #acacac;
    margin-left: 5px;
}
.el-progress /deep/ path:first-child {
   stroke: #6e7c9b42;
 }

</style>